<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fns.tld" prefix="fns" %>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <jsp:include page="/resources/inc/head.jsp" />
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/demo.css" rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/metroStyle/metroStyle.css" rel="stylesheet"/>
</head>
<body>

<form class="layui-form layui-form-pane" id="_form">
    <div class="layui-form-item">
        <label class="layui-form-label">计划部门</label>
        <div class="layui-input-block">
            <input type="text" readonly="readonly" id="organization" ztreeId="organizationTree" lay-verify="required"
                   placeholder="请选择部门" class="layui-input" onclick="ZtreeCommon.pageShowMenu(this)"
                   value="${organization.name}">
            <input type="hidden" id="organizationId" name="deptId" value="${organization.organizationId}">
            <div class="menuContent" style="display:none; position: absolute;z-index: 10000">
                <ul id="organizationTree" class="ztree" style="margin-top:0; width:220px;"></ul>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">计划名称</label>
        <div class="layui-input-block">
            <input type="text" name="planName" lay-verify="required" autocomplete="off" placeholder="请输入部门年计划名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">计划年份</label>
        <div class="layui-input-block">
            <input type="text" name="planYear" autocomplete="off" id="year"
                   placeholder="请选择计划年份" value="${year}"
                   class="layui-input" readonly="readonly">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">计划月份</label>
        <div class="layui-input-block">

            <select name="planMonth" lay-verify="required">
                <option value="" selected="selected">请选择计划月份</option>
                <option value="1"
                        <c:if test="${month == 1}">
                            selected="selected"
                        </c:if>
                >1
                </option>
                <option value="2"
                        <c:if test="${month == 2}">
                            selected="selected"
                        </c:if>
                >2
                </option>
                <option value="3"
                        <c:if test="${month == 3}">
                            selected="selected"
                        </c:if>
                >3
                </option>
                <option value="4"
                        <c:if test="${month == 4}">
                            selected="selected"
                        </c:if>
                >4
                </option>
                <option value="5"
                        <c:if test="${month == 5}">
                            selected="selected"
                        </c:if>
                >5
                </option>
                <option value="6"
                        <c:if test="${month == 6}">
                            selected="selected"
                        </c:if>
                >6
                </option>
                <option value="7"
                        <c:if test="${month == 7}">
                            selected="selected"
                        </c:if>
                >7
                </option>
                <option value="8"
                        <c:if test="${month == 8}">
                            selected="selected"
                        </c:if>
                >8
                </option>
                <option value="9"
                        <c:if test="${month == 9}">
                            selected="selected"
                        </c:if>
                >9
                </option>
                <option value="10"
                        <c:if test="${month == 10}">
                            selected="selected"
                        </c:if>
                >10
                </option>
                <option value="11"
                        <c:if test="${month == 11}">
                            selected="selected"
                        </c:if>
                >11
                </option>
                <option value="12"
                        <c:if test="${month == 12}">
                            selected="selected"
                        </c:if>
                >12
                </option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">计划详情</label>
        <div class="layui-input-block">
            <textarea id="planDetail" name="planDetail" style="display: none;"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" autocomplete="off" placeholder="请输入备注" class="layui-textarea"></textarea>
        </div>
    </div>
    <%--todo 上传组件--%>
    <div class="layui-form-item">
        <div class="layui-input-block" style="float: right">
            <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
        </div>
    </div>
</form>
<jsp:include page="/resources/inc/pageFooter.jsp" />
<script src="${basePath}/resources/zheng-admin/js/my-ztree-common.js"></script>
<script>
    var layedit;
    var editIndex;
    var organizationNodes = getOrganizationTree(true, false);
    var organizationId = ${organization.organizationId};
    $(function () {
        layui.use(['laydate', 'layedit'], function () {
            layedit = layui.layedit;
            editIndex = layedit.build('planDetail', {
                tool: [
                    'strong' //加粗
                    , 'italic' //斜体
                    , 'underline' //下划线
                    , 'del' //删除线
                    , '|' //分割线
                    , 'left' //左对齐
                    , 'center' //居中对齐
                    , 'right' //右对齐
                    , 'link' //超链接
                    , 'unlink' //清除链接
                    , 'face' //表情

                ]
            }); //建立编辑器
            var laydate = layui.laydate;
            laydate.render({
                elem: "#year" //指定元素
                , theme: '#393D49'
                , type: 'year'
            });
        });
        //提交方法
        FormCommon.initForm({
            url: "${basePath}/oa/wc/deptMonthPlan/create",
            subContentType: "json",
            editData: function (data) {
                data.planDetail = layedit.getContent(editIndex);
                return data;
            }
        });
        var organizationTree = $.fn.zTree.init($("#organizationTree"), ZtreeCommon.radioAllSetting, organizationNodes);
        $(organizationNodes).each(function (index, node) {
            if (node.id == organizationId) {
                var nodes = organizationTree.getNodesByParam("id", organizationId, null);
                organizationTree.checkNode(nodes[0], true, true);
                return false;
            }
        });
    });
    //填充数据
</script>
</body>
</html>
